/** 
 * Copyright (C), 2010-2012, AIYOU Software Co.,Ltd. ALL RIGHTS RESERVED. 
 * File name:CommodityAction.java
 * Version:1.0
 * Date:2011-12-17
 * Description: 
 * author:TT_LOVE
 */
package com.tietiao.action.favorite;

import java.util.List;
import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.tietiao.common.action.BaseAction;
import com.tietiao.common.util.StringUtil;
import com.tietiao.dao.model.CommodityInfo;
import com.tietiao.dao.model.SysUser;
import com.tietiao.dao.model.UserCommidityFavorite;
import com.tietiao.service.commodity.CommodityService;

@Controller
@Scope("prototype")
@SuppressWarnings("serial")
public class FavoriteAction extends BaseAction {
	@Resource
	private CommodityService commodityService;
	// 商品列表信息
	private List<CommodityInfo> commodityInfoList;
	// 排序
	private String orderType = "TIETIAO_NUM DESC";
	// 用户信息
	private SysUser userInfo;
	// 收藏夹名称
	private String favoriteName;
	
	/**
	 * 
	 * 功能：收藏夹信息页面
	 * @author: TT_LOVE
	 * @Date: 2012-1-15
	 *
	 * @return
	 */
	public String favoriteInfo() {
		favoriteName = request.getParameter("favoriteName");
		favoriteName = StringUtil.ISO88591_TO_UTF8(favoriteName);
		return DEFAULT;
	}

	/**
	 * 
	 * 功能：加载收藏夹下商品信息
	 * @author: TT_LOVE
	 * @Date: 2012-1-15
	 *
	 * @return
	 */
	public String loadCommodityInfo(){
		Integer userId = null;
		if (getUser() != null) {
			userId = getUser().getUserId();
		}
		String favoriteName = request.getParameter("favoriteName");
		UserCommidityFavorite userCommidityFavorite = new UserCommidityFavorite();
		if(StringUtils.isNotBlank(favoriteName)){
			userCommidityFavorite.setFavoriteName(StringUtil.decode(favoriteName));
			commodityInfoList = commodityService.searchCommodityInfoByFavoriteInfo(userCommidityFavorite, userId, null, null, orderType);
		}
		return DEFAULT;
	}
	
	
	/**
	 * @return the commodityService
	 */
	public CommodityService getCommodityService() {
		return commodityService;
	}

	/**
	 * @param commodityService
	 *            the commodityService to set
	 */
	public void setCommodityService(CommodityService commodityService) {
		this.commodityService = commodityService;
	}

	/**
	 * @return the commodityInfoList
	 */
	public List<CommodityInfo> getCommodityInfoList() {
		return commodityInfoList;
	}

	/**
	 * @param commodityInfoList
	 *            the commodityInfoList to set
	 */
	public void setCommodityInfoList(List<CommodityInfo> commodityInfoList) {
		this.commodityInfoList = commodityInfoList;
	}

	/**
	 * @return the orderType
	 */
	public String getOrderType() {
		return orderType;
	}

	/**
	 * @param orderType
	 *            the orderType to set
	 */
	public void setOrderType(String orderType) {
		this.orderType = orderType;
	}

	/**
	 * @return the rootPicPath
	 */
	public String getRootPicPath() {
		return rootPicPath;
	}

	/**
	 * @param rootPicPath
	 *            the rootPicPath to set
	 */
	public void setRootPicPath(String rootPicPath) {
		this.rootPicPath = rootPicPath;
	}

	/**
	 * @return the userInfo
	 */
	public SysUser getUserInfo() {
		return userInfo;
	}

	/**
	 * @param userInfo
	 *            the userInfo to set
	 */
	public void setUserInfo(SysUser userInfo) {
		this.userInfo = userInfo;
	}

	/**
	 * @return the favoriteName
	 */
	public String getFavoriteName() {
		return favoriteName;
	}

	/**
	 * @param favoriteName the favoriteName to set
	 */
	public void setFavoriteName(String favoriteName) {
		this.favoriteName = favoriteName;
	}
}
